function onCheckedService()
{
	var check = document.getElementById("search_loc_id");
	if (null != check)
	{
		return;
	}

	var searchLocations = createInputRadio("search_loc_id", "search_option",
			"search_locations");
	var searchKeywords = createInputRadio("search_key_id", "search_option",
			"search_keywords");

	var options = document.getElementById("search_options");
	options.appendChild(searchLocations);
	options.appendChild(document.createTextNode("search locations"));
	options.appendChild(document.createElement("br"));
	options.appendChild(document.createTextNode("longtitude"));
	options.appendChild(createInputText("lat", "x", 6));
	options.appendChild(document.createTextNode("latitude"));
	options.appendChild(createInputText("lng", "y", 6));
	options.appendChild(document.createTextNode("radius"));
	options.appendChild(createInputText("radius", "r", 6));

	options.appendChild(document.createElement("br"));
	options.appendChild(searchKeywords);
	options.appendChild(document.createTextNode("search keywords"));
	options.appendChild(document.createElement("br"));
	options.appendChild(document.createTextNode("keywords(seperted by space)"));
	options.appendChild(createInputText("keywords", "k", 26));

	var button = document.getElementById("search_button");
	button.style.display = 'block';
}

function createInputRadio(id, name, value)
{
	var input = document.createElement("input");
	input.id = id;
	input.type = "radio";
	input.name = name;
	input.value = value;
	return input;

}

function createInputText(id, name, size)
{
	var input = document.createElement("input");
	input.type = "text";
	input.id = id;
	input.name = name;
	input.size = size;
	return input;

}

function searchWebServices(form)
{
	var search = new Object();
	search.url = getSelectedValue(form.endpoint);
	if (null == search.url)
	{
		alert("you must choose an end point");
		return;
	}

	search.method = getSelectedValue(form.search_option);
	if (null == search.method)
	{
		alert("you must choose search option");
		return;
	}
	if ("search_locations" == search.method)
	{
		search.lat = form.lat.value;
		search.lng = form.lng.value;
		search.radius = form.radius.value;
		if (null == search.lat || null == search.lng || null == search.radius)
		{
			alert("you must enter values...");
			return;
		}
		search.keywords = null;
	} else if ("search_keywords" == search.method)
	{
		search.keywords = form.keywords.value;
		if (null == search.keywords)
		{
			alert("you must enter values...");
			return;
		}
		search.lat = null;
		search.lng = null;
		search.radius = null;
	}
	$.ajax(
	{
		type : 'POST',
		contentType : 'application/json',
		url : '/${project.build.finalName}/restful-services/user-api/service',
		dataType : "json",
		data : JSON.stringify(search),
		success : function(data, textStatus, jqXHR)
		{
			var res = "";
			for ( var i = 0; i < data.length; ++i)
			{
				res += data[i];
				res += "\n";
			}
			alert(res);
		},
		error : function(jqXHR, textStatus, errorThrown)
		{
			alert(jqXHR.status);
		}

	});

}

function getSelectedValue(radio)
{
	for ( var i = 0; i < radio.length; ++i)
	{
		if (radio[i].checked)
		{
			return radio[i].value;
		}
	}
	return null;
}
